{use_macro file="Dataface_Main_Template.html"}
	{fill_slot name="main_column"}

		<h1>General Ledger: Close {$period_type}</h1>
		<br>

		{if $period_select}
			<p>Please Select from the Following Periods:</p>
			<form name="select_date">
				<input type="hidden" name="-action" value="close_ledger">
				<input type="hidden" name="action_section" value="display">
				<select name="period_range">
					<option value="">Please Select...</option>
					{foreach from=$period_select key=i item=period}
						<option value="{$period}">{$i}</option>
					{/foreach}
				</select>
	
				<input type="submit" value="Submit">
			</form>
		{elseif $unposted}
			<p class="portalMessage">The following journal entries have not been posted. Cannot close {$period_type}</p>
			
			<table class="listing resultList">
				<tr>
					<th>ID</th>
					<th>Date</th>
					<th>Description</th>
				</tr>
				{$i = 0}
				{foreach from=$unposted item=list}
					{if $i%2 == 0}
						<tr class="listing odd">
					{else}
						<tr class="listing even">
					{/if}
						<td valign="top"><a href="index.php?-table=general_ledger&-action=browse&-recordid=general_ledger?ledger_id={$list.ledger_id}">{$list.ledger_id}</a></td>
						<td valign="top"><a href="index.php?-table=general_ledger&-action=browse&-recordid=general_ledger?ledger_id={$list.ledger_id}">{$list.ledger_date.day}-{$list.ledger_date.month}-{$list.ledger_date.year}</a></td>
						<td valign="top"><a href="index.php?-table=general_ledger&-action=browse&-recordid=general_ledger?ledger_id={$list.ledger_id}">{$list.ledger_description}</a></td>
					</tr>
					{assign var="i" value=$i+1}
				{/foreach}
			</table>
		{elseif $accounts}
			<table class="listing resultList">
				<tr>
					<th>Account</th>
					<th>Name</th>
					<th>Debit</th>
					<th>Credit</th>
				</tr>
				{$i = 0}
				{foreach from=$accounts item=list}
					{if $i%2 == 0}
						<tr class="listing odd">
					{else}
						<tr class="listing even">
					{/if}
						<td valign="top">{$list.account_number}</td>
						<td valign="top">{$list.account_name}</td>
						<td valign="top" style="text-align: right;">{$list.debit}</td>
						<td valign="top" style="text-align: right;">{$list.credit}</td>
					</tr>
					{assign var="i" value=$i+1}
				{/foreach}
				<tr>
					{if $total_debit == $total_credit}{assign var="color" value="lightgreen"}{else}{assign var="color" value="#ff7070"}{/if}
					<td></td><td>TOTAL</td><td style="background-color: {$color}; text-align: right;">{$total_debit}</td><td style="background-color: {$color}; text-align: right;">{$total_credit}</td>
				</tr>
			</table>

			<form name="confirm_close">
				<input type="hidden" name="-action" value="close_ledger">
				<input type="hidden" name="action_section" value="confirm">
				<input type="hidden" name="period_range" value="{$period_range}">
				<input type="submit" value="Confirm">
			</form>

		{/if}


		


	{/fill_slot}
{/use_macro}